package com.example.homework.homework01;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Account {
    private String name; // 卡号
    private double money; // 余额

    // 存钱的方法
    public void deposit(double money) {
        // 拿到当前谁来存钱。
        String name = Thread.currentThread().getName();
        synchronized (this) {
            this.money += money;
            System.out.println(name + "存钱成功，存入了" + money + "元！" + "余额是" + this.money);
        }
    }
}
